C1.LiveLinq Namespace > LiveViewExtensions Class > LiveAverage Method : LiveAverage<TSource>(View<TSource>,Expression<Func<TSource,Nullable<Int32>>>) Method |
'Declaration
Public Overloads Shared Function LiveAverage(Of TSource)( _ ByVal source As View(Of TSource), _ ByVal selector As System.Linq.Expressions.Expression(Of Func(Of TSource,Nullable(Of Integer))) _ ) As AggregationView(Of TSource,Nullable(Of Double))
public static AggregationView<TSource,Nullable<double>> LiveAverage<TSource>( View<TSource> source, System.Linq.Expressions.Expression<Func<TSource,Nullable<int>>> selector )
If the source is empty, the average value is null.
It is possible to use standard LINQ query operator Average instead of LiveAverage. Both are "live" in the sense that they are recomputed automatically when any change occurs in the source. The difference is that Average will every time loop through the entire source collection and aggregate it from scratch, whereas LiveAverage will use a more performant algorithm, will maintain its value incrementally, processing only those source items that actually changed.
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2